package org.eclipse.rally.plugin.views;

import java.util.Calendar;

import org.eclipse.rally.plugin.utils.SWTResourceManager;
import org.eclipse.rally.plugin.utils.UserUtil;
import org.eclipse.rally.plugin.webservice.RallyMain;
import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.custom.CCombo;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseTrackAdapter;
import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.Text;

import com.rallydev.webservice.v1_12.domain.Task;

public class EditTaskDetailGUI {
	public static Shell shell;
	public static Composite composite;
	public static ScrolledComposite scrolledComposite;
	public static DefectDetailGUI dbg;
	public static Group group;
	private static Text attachVal,EstimateValue,toDoValue,actualValue,fixedCheckedINValue,attachment,addNoteValue;
	private static Task task;
	private static StyledText nameValue;
	private static Browser descValue,notesValue;
	private static CCombo ownerValue,stateCombo;
	private static Button blockedCheck ;
	private static Link workProd;
	

	
	/**
	 * Launch the application.
	 * 
	 * @param args
	 */
	public static void main(String args[]) {
		Display display = new Display();
		shell = new Shell(display);
		shell.setMinimumSize(new Point(400, 1200));
		shell.setLayout(new FillLayout());
		
		String id = "DE5731";
		TabFolder tabFolder = new TabFolder(shell, SWT.NONE);
		TabItem tabItem = new TabItem(tabFolder, SWT.NONE);
		tabItem.setText("Edit Task&Detail");
		new EditTaskDetailGUI().editTaskDetail(tabFolder, tabItem, id,"Task");

		shell.setSize(900, 894);
		shell.open();

		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}

		display.dispose();
	}

	public void editTaskDetail(final TabFolder tabFolder,
			final TabItem tabItem, final String taskRef, final String pageName) {
		try{
			
		 task = (Task) RallyMain.readTaskObject(taskRef);
		
		scrolledComposite = new ScrolledComposite(tabFolder, SWT.BORDER
				| SWT.H_SCROLL | SWT.V_SCROLL);
		tabItem.setControl(scrolledComposite);
		scrolledComposite.setExpandHorizontal(true);
		scrolledComposite.setExpandVertical(true);
		composite = new Composite(scrolledComposite, SWT.BORDER);
		composite.setBackground(SWTResourceManager
				.getColor(SWT.COLOR_LIST_BACKGROUND));
		group = new Group(composite, SWT.BORDER);
		//group.setEnabled(false);
		group.setBackground(SWTResourceManager
				.getColor(SWT.COLOR_LIST_BACKGROUND));
		group.setBounds(10, 10, 850, 1095);

		Label lblGeneral = new Label(group, SWT.BORDER);
		lblGeneral.setBounds(0, 0, 168, 21);
		lblGeneral.setText("General");
		lblGeneral.setForeground(SWTResourceManager.getColor(0, 0, 0));
		lblGeneral.setFont(SWTResourceManager.getFont("Tahoma", 10, SWT.BOLD));
		lblGeneral.setBackground(SWTResourceManager.getColor(122, 150, 223));
		
		{
		final Label backButton = new Label(group, SWT.NONE);

		backButton.setBackground(SWTResourceManager
				.getColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND));
		backButton.setImage(SWTResourceManager.getImage(
				EditTaskDetailGUI.class, "/icons/Back-enabled.gif"));
		backButton.setBounds(752, 0, 44, 20);
		backButton.addMouseTrackListener(new MouseTrackAdapter() {
			@Override
			public void mouseHover(MouseEvent e) {
				final Cursor cursor = new Cursor(Display.getCurrent(),
						SWT.CURSOR_HAND);

				backButton.setCursor(cursor);

			}
		});
		backButton.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseDown(MouseEvent e) {
				System.out.println("entering into addMouseListener....");
				composite.dispose();
				group.dispose();
				/*
				 * System.out.println("task  dashboard");
				 * JOptionPane.showMessageDialog(null, "task", "", 0);
				 */
				new TaskDetailGUI().backToTaskDetailPage(tabFolder, tabItem, taskRef, pageName);
			}
		});
	}
		Label lblGrpBorder = new Label(group, SWT.NONE);
		lblGrpBorder.setBounds(167, 0, 683, 20);
		lblGrpBorder.setBackground(SWTResourceManager.getColor(122, 150, 223));

		Label lblId = new Label(group, SWT.BORDER | SWT.RIGHT);
		lblId.setBounds(0, 20, 166, 21);
		lblId.setText("ID :");
		lblId.setForeground(SWTResourceManager.getColor(0, 0, 0));
		lblId.setFont(SWTResourceManager.getFont("Tahoma", 9, SWT.NORMAL));
		lblId.setBackground(SWTResourceManager.getColor(216, 228, 248));

		Label lblName = new Label(group, SWT.BORDER | SWT.RIGHT);
		lblName.setBounds(0, 41, 166, 50);
		lblName.setText("Name:");
		lblName.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
		lblName.setFont(SWTResourceManager.getFont("Tahoma", 9, SWT.NORMAL));
		lblName.setBackground(SWTResourceManager.getColor(SWT.COLOR_DARK_RED));

		Label lblDescription = new Label(group, SWT.BORDER | SWT.RIGHT);
		lblDescription.setBounds(0, 91, 166, 256);
		lblDescription.setText("Description:");
		lblDescription.setForeground(SWTResourceManager.getColor(0, 0, 0));
		lblDescription.setFont(SWTResourceManager.getFont("Tahoma", 9,
				SWT.NORMAL));
		lblDescription
				.setBackground(SWTResourceManager.getColor(216, 228, 248));

		Label lblAttachmet = new Label(group, SWT.BORDER | SWT.RIGHT);
		lblAttachmet.setBounds(1, 347, 166, 65);
		lblAttachmet.setText("Attachments:");
		lblAttachmet.setForeground(SWTResourceManager.getColor(0, 0, 0));
		lblAttachmet.setFont(SWTResourceManager
				.getFont("Tahoma", 9, SWT.NORMAL));
		lblAttachmet.setBackground(SWTResourceManager.getColor(216, 228, 248));

		Label lblOwner = new Label(group, SWT.BORDER | SWT.RIGHT);
		lblOwner.setBounds(1, 411, 166, 23);
		lblOwner.setText("Owner:");
		lblOwner.setForeground(SWTResourceManager.getColor(0, 0, 0));
		lblOwner.setFont(SWTResourceManager.getFont("Tahoma", 9, SWT.NORMAL));
		lblOwner.setBackground(SWTResourceManager.getColor(216, 228, 248));

		Label lblProject = new Label(group, SWT.BORDER | SWT.RIGHT);
		lblProject.setBounds(1, 434, 166, 24);
		lblProject.setText("Project:");
		lblProject.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
		lblProject.setFont(SWTResourceManager.getFont("Tahoma", 9, SWT.NORMAL));
		lblProject.setBackground(SWTResourceManager.getColor(SWT.COLOR_DARK_RED));

		Label lblTask = new Label(group, SWT.BORDER);
		lblTask.setBounds(0, 457, 168, 21);
		lblTask.setText("Task");
		lblTask.setForeground(SWTResourceManager.getColor(0, 0, 0));
		lblTask.setFont(SWTResourceManager.getFont("Tahoma", 10, SWT.BOLD));
		lblTask.setBackground(SWTResourceManager.getColor(122, 150, 223));

		Label label_2 = new Label(group, SWT.BORDER);
		label_2.setBounds(164, 474, 683, 3);
		label_2.setForeground(SWTResourceManager.getColor(0, 0, 0));
		label_2.setFont(SWTResourceManager.getFont("Times New Roman", 13,
				SWT.BOLD));
		label_2.setBackground(SWTResourceManager.getColor(122, 150, 223));

		Label lblState = new Label(group, SWT.BORDER | SWT.RIGHT);
		lblState.setBounds(1, 477, 166, 21);
		lblState.setText("State:");
		lblState.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
		lblState.setFont(SWTResourceManager.getFont("Tahoma", 9, SWT.NORMAL));
		lblState.setBackground(SWTResourceManager.getColor(SWT.COLOR_DARK_RED));

		Label lblEstimate = new Label(group, SWT.BORDER | SWT.RIGHT);
		lblEstimate.setBounds(1, 497, 166, 21);
		lblEstimate.setText("Estimate:");
		lblEstimate.setForeground(SWTResourceManager.getColor(0, 0, 0));
		lblEstimate
				.setFont(SWTResourceManager.getFont("Tahoma", 9, SWT.NORMAL));
		lblEstimate.setBackground(SWTResourceManager.getColor(216, 228, 248));

		Label lblToDO = new Label(group, SWT.BORDER | SWT.RIGHT);
		lblToDO.setBounds(1, 517, 166, 21);
		lblToDO.setText("To Do:");
		lblToDO.setForeground(SWTResourceManager.getColor(0, 0, 0));
		lblToDO.setFont(SWTResourceManager.getFont("Tahoma", 9, SWT.NORMAL));
		lblToDO.setBackground(SWTResourceManager.getColor(216, 228, 248));

		Label lblWorkProd = new Label(group, SWT.BORDER | SWT.RIGHT);
		lblWorkProd.setBounds(1, 538, 166, 43);
		lblWorkProd.setText("Work Product:");
		lblWorkProd.setForeground(SWTResourceManager.getColor(0, 0, 0));
		lblWorkProd
				.setFont(SWTResourceManager.getFont("Tahoma", 9, SWT.NORMAL));
		lblWorkProd.setBackground(SWTResourceManager.getColor(216, 228, 248));

		Label lblBlocked = new Label(group, SWT.BORDER | SWT.RIGHT);
		lblBlocked.setBounds(531, 477, 119, 21);
		lblBlocked.setText("Blocked:");
		lblBlocked.setForeground(SWTResourceManager.getColor(0, 0, 0));
		lblBlocked.setFont(SWTResourceManager.getFont("Tahoma", 9, SWT.NORMAL));
		lblBlocked.setBackground(SWTResourceManager.getColor(216, 228, 248));

		Label lblActuals = new Label(group, SWT.BORDER | SWT.RIGHT);
		lblActuals.setBounds(531, 497, 119, 21);
		lblActuals.setText("Actuals:");
		lblActuals.setForeground(SWTResourceManager.getColor(0, 0, 0));
		lblActuals.setFont(SWTResourceManager.getFont("Tahoma", 9, SWT.NORMAL));
		lblActuals.setBackground(SWTResourceManager.getColor(216, 228, 248));

		Label lblCustom = new Label(group, SWT.BORDER);
		lblCustom.setBounds(1, 581, 166, 21);
		lblCustom.setText("Custom");
		lblCustom.setForeground(SWTResourceManager.getColor(0, 0, 0));
		lblCustom.setFont(SWTResourceManager.getFont("Tahoma", 10, SWT.BOLD));
		lblCustom.setBackground(SWTResourceManager.getColor(122, 150, 223));

		Label lblFixedCheckedIN = new Label(group, SWT.BORDER | SWT.RIGHT);
		lblFixedCheckedIN.setBounds(1, 602, 166, 52);
		lblFixedCheckedIN.setText("Fixed / Checked IN:");
		lblFixedCheckedIN.setForeground(SWTResourceManager.getColor(0, 0, 0));
		lblFixedCheckedIN.setFont(SWTResourceManager.getFont("Tahoma", 9,
				SWT.NORMAL));
		lblFixedCheckedIN.setBackground(SWTResourceManager.getColor(216, 228,
				248));

		Label lblNotesTitle = new Label(group, SWT.BORDER);
		lblNotesTitle.setBounds(1, 652, 166, 21);
		lblNotesTitle.setText("Notes");
		lblNotesTitle.setForeground(SWTResourceManager.getColor(0, 0, 0));
		lblNotesTitle.setFont(SWTResourceManager
				.getFont("Tahoma", 10, SWT.BOLD));
		lblNotesTitle.setBackground(SWTResourceManager.getColor(122, 150, 223));

		Label lblNotes = new Label(group, SWT.BORDER | SWT.RIGHT);
		lblNotes.setBounds(1, 673, 166, 336);
		lblNotes.setText("Notes :");
		lblNotes.setForeground(SWTResourceManager.getColor(0, 0, 0));
		lblNotes.setFont(SWTResourceManager.getFont("Tahoma", 9, SWT.NORMAL));
		lblNotes.setBackground(SWTResourceManager.getColor(216, 228, 248));

		Label label_1 = new Label(group, SWT.BORDER);
		label_1.setBounds(167, 599, 683, 3);
		label_1.setForeground(SWTResourceManager.getColor(0, 0, 0));
		label_1.setFont(SWTResourceManager.getFont("Times New Roman", 13,
				SWT.BOLD));
		label_1.setBackground(SWTResourceManager.getColor(122, 150, 223));

		Label label_3 = new Label(group, SWT.BORDER);
		label_3.setBounds(167, 670, 683, 3);
		label_3.setForeground(SWTResourceManager.getColor(0, 0, 0));
		label_3.setFont(SWTResourceManager.getFont("Times New Roman", 13,
				SWT.BOLD));
		label_3.setBackground(SWTResourceManager.getColor(122, 150, 223));

		Label label_5 = new Label(group, SWT.NONE);
		label_5.setBounds(0, 1049, 166, 2);
		label_5.setBackground(SWTResourceManager.getColor(122, 150, 223));

		Label idValue = new Label(group, SWT.RIGHT);
		idValue.setBounds(170, 21, 166, 20);
		if(task.getFormattedID() != null)
			idValue.setText(task.getFormattedID());
		else
			idValue.setText("");
		
		idValue.setForeground(SWTResourceManager.getColor(0, 0, 0));
		idValue.setFont(SWTResourceManager.getFont("Tahoma", 9, SWT.NORMAL));
		idValue.setBackground(SWTResourceManager.getColor(255, 255, 255));
		idValue.setAlignment(SWT.LEFT);

		 nameValue = new StyledText(group, SWT.BORDER | SWT.SINGLE);
		//nameValue.setEnabled(true);
		if(task.getName() != null)
			nameValue.setText(task.getName());
		else
			nameValue.setText("");
		nameValue.setEditable(true);
		nameValue.setBounds(170, 42, 679, 49);

		 descValue = new Browser(group, SWT.BORDER);
		descValue.setBounds(170, 93, 679, 247);
		
		if (task.getDescription() != null){
			String description = 	task.getDescription().replace("<br>","\n\n");
			descValue.setText(description);
		}
		else {
			descValue.setText("");
		}
		descValue.setEnabled(true);
		descValue.setBackground(SWTResourceManager
				.getColor(SWT.COLOR_WIDGET_LIGHT_SHADOW));
		descValue.setEnabled(true);
		descValue.setForeground(SWTResourceManager.getColor(0, 0, 0));
		descValue.setFont(SWTResourceManager.getFont("Tahoma", 9,
				SWT.NORMAL));
		descValue
				.setBackground(SWTResourceManager.getColor(255, 255, 255));

		attachVal = new Text(group, SWT.BORDER);
		attachVal.setBounds(170, 347, 672, 23);

		Label projectValue = new Label(group, SWT.NONE);
		//projectValue.setBackground(com.swtdesigner.SWTResourceManager.getColor(SWT.COLOR_LIST_SELECTION_TEXT));
		//projectValue.setEditable(true);
		projectValue.setBounds(170, 434, 179, 24);
		if(task.getProject() != null && task.getProject().getRefObjectName() != null)
			projectValue.setText(task.getProject().getRefObjectName());
		else
			projectValue.setText("");
		projectValue.setForeground(SWTResourceManager.getColor(0, 0, 0));
		projectValue.setFont(SWTResourceManager.getFont("Tahoma", 9, SWT.NORMAL));
		projectValue.setBackground(SWTResourceManager.getColor(255, 255, 255));
		projectValue.setAlignment(SWT.LEFT);
			

		 ownerValue = new CCombo(group, SWT.BORDER);
		if(task.getOwner() != null && UserUtil.getUsrName(task.getOwner()) != null)
			ownerValue.setText(UserUtil.getUsrName(task.getOwner()));
    		else
    			ownerValue.setText("");
		ownerValue.setBounds(170, 411, 179, 21);
		UserUtil.setUsers(ownerValue);
		
		 stateCombo = new CCombo(group, SWT.BORDER);
		System.out.println("value of the state "+task.getState());
		if(task.getState() != null){
			stateCombo.setText(task.getState());
		}
	
		stateCombo.setBounds(170, 477, 91, 21);
		stateCombo.setItems(new String[] {"In-Progress", "Completed", "Defined"});
		
		
		EstimateValue = new Text(group, SWT.BORDER);
		if(task.getEstimate() != null)
			EstimateValue.setText(String.valueOf(task.getEstimate()));
		else 
			EstimateValue.setText("");
		EstimateValue.setBounds(170, 499, 91, 19);

		Label lblHours = new Label(group, SWT.NONE);
		lblHours.setBackground(SWTResourceManager
				.getColor(SWT.COLOR_LIST_BACKGROUND));
		lblHours.setBounds(267, 499, 49, 19);
		lblHours.setText("Hours");

		toDoValue = new Text(group, SWT.BORDER);
		if(task.getToDo() != null)
			toDoValue.setText(String.valueOf(task.getToDo()));
		else
			toDoValue.setText("");
		toDoValue.setBounds(170, 519, 91, 19);

		Label label_6 = new Label(group, SWT.NONE);
		label_6.setBounds(267, 519, 49, 19);
		label_6.setText("Hours");
		label_6.setBackground(SWTResourceManager
				.getColor(SWT.COLOR_LIST_BACKGROUND));

		 blockedCheck = new Button(group, SWT.CHECK);
		blockedCheck.setForeground(SWTResourceManager
				.getColor(SWT.COLOR_LIST_BACKGROUND));
		blockedCheck.setBackground(SWTResourceManager
				.getColor(SWT.COLOR_LIST_BACKGROUND));
		//System.out.println("value of the blocked*****"+task.getBlocked());
		if(task.getBlocked())
			blockedCheck.setSelection(true);
		else
			blockedCheck.setSelection(false);
			
			
		// button.setGrayed(true);
		blockedCheck.setBounds(656, 474, 18, 21);

		actualValue = new Text(group, SWT.BORDER);
		if (task.getActuals() != null)
			actualValue.setText(String.valueOf(task.getActuals()));
		else
			actualValue.setText("");
		actualValue.setBounds(656, 497, 68, 19);

		Label label_7 = new Label(group, SWT.NONE);
		label_7.setBounds(730, 499, 49, 19);
		label_7.setText("Hours");
		label_7.setBackground(SWTResourceManager
				.getColor(SWT.COLOR_LIST_BACKGROUND));

		fixedCheckedINValue = new Text(group, SWT.BORDER);
		if (task.getFixedCheckedIN() != null)
			fixedCheckedINValue.setText(task.getFixedCheckedIN());
		else
			fixedCheckedINValue.setText("");
		fixedCheckedINValue.setBounds(170, 602, 679, 52);
		fixedCheckedINValue.setEditable(true);

		 notesValue = new Browser(group, SWT.BORDER);
		if (task.getNotes() != null)
			notesValue.setText(task.getNotes());
		else
			notesValue.setText("");
		notesValue.setBounds(170, 675, 679, 334);
		notesValue.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
		notesValue.setFont(SWTResourceManager.getFont("Tahoma", 9, SWT.NORMAL));
		notesValue.setBackground(SWTResourceManager
				.getColor(SWT.COLOR_LIST_BACKGROUND));
		
		Button submitButton = new Button(group, SWT.NONE);
		submitButton.setBounds(480, 1062, 68, 23);
		submitButton.setText("Submit");
	
		submitButton.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseDown(MouseEvent e) {
               	 //System.out.println("in submit()");
               	 try{
               	 editTaskDetails();
               	 composite.dispose();
                 group.dispose();
                 new TaskDetailGUI().backToTaskDetailPage(tabFolder, tabItem, taskRef,pageName);
                 /*int i=2;
                 dbg =new DefectDetailGUI();
                 dbg.defectDetail(tabFolder, tabItem, defectRefrence, i);*/
               	 }catch (Exception e1) {
						e1.printStackTrace();
					}
               	 //System.out.println("End of submit()");
                }
            });
        
		
		Label lblAddNote = new Label(group, SWT.BORDER | SWT.RIGHT);
		lblAddNote.setBounds(0, 1010, 166, 41);
		lblAddNote.setText("Add Note :");
		lblAddNote.setForeground(SWTResourceManager.getColor(0, 0, 0));
		lblAddNote.setFont(SWTResourceManager.getFont("Tahoma", 9, SWT.NORMAL));
		lblAddNote.setBackground(SWTResourceManager.getColor(216, 228, 248));
		
		addNoteValue = new Text(group, SWT.BORDER);
		addNoteValue.setBounds(170, 1010, 672, 41);
		addNoteValue.setBackground(SWTResourceManager.getColor(255, 255, 255));
		
		Label label = new Label(group, SWT.SEPARATOR);
		label.setBounds(167, 20, 1, 1031);
		label.setForeground(SWTResourceManager.getColor(49, 106, 197));
		label.setBackground(SWTResourceManager.getColor(49, 106, 197));
		
		attachment = new Text(group, SWT.BORDER);
		attachment.setBounds(170, 376, 286, 19);
		
		Button browseButton = new Button(group, SWT.NONE);
		browseButton.setBounds(477, 376, 68, 20);
		browseButton.setText("Browse");
		
		 workProd = new Link(group, SWT.RIGHT);
		workProd.setBounds(170, 541, 660, 52);
		if (task.getWorkProduct() != null
				&& task.getWorkProduct().getRef() != null)
			workProd.setText(TaskDetailGUI.getWorkProductName(task.getWorkProduct()
					.getRef()));
		else
			workProd.setText("");
		workProd.setForeground(SWTResourceManager.getColor(0, 0, 0));
		workProd.setFont(SWTResourceManager.getFont("Tahoma", 9, SWT.NORMAL));
		workProd.setBackground(SWTResourceManager.getColor(255, 255, 255));
		
		
		browseButton.addListener(SWT.Selection, new Listener() {
		      public void handleEvent(Event event) {
		    	final Shell dialog = new Shell (shell, SWT.DIALOG_TRIM);
		        FileDialog fileDialog = new FileDialog(dialog, SWT.MULTI);
		        String fileFilterPath = "F:/jdk1.5";
		        fileDialog.setFilterPath(fileFilterPath);
		        
		        fileDialog.setFilterExtensions(new String[]{"*.rtf", "*.html", "*.*"});
		        fileDialog.setFilterNames(new String[]{ "Rich Text Format", "HTML Document", "Any"});
		        
		        String firstFile = fileDialog.open();

		        if(firstFile != null) {
		          fileFilterPath = fileDialog.getFilterPath();
		          String[] selectedFiles = fileDialog.getFileNames();
		          StringBuffer sb = new StringBuffer(fileDialog.getFilterPath());
		          for(int i=0; i<selectedFiles.length; i++) {
		            sb.append(selectedFiles[i]);
		          }
		          attachment.setText(sb.toString());
		        }
		        dialog.pack();
			    dialog.open();
			    dialog.close();
		      }
		      
		    });
		
		  
		scrolledComposite.setContent(composite);
		scrolledComposite.setMinSize(new Point(859, 1200));
		}catch(Exception e){
        	e.printStackTrace();
        	
        }
	}
	
	private static void editTaskDetails(){
    	System.out.println("task=="+task);
    	if(task != null){
    		//System.out.println("in editTaskDetails method");
    		if(nameValue.getText() != null){
    			
    			//System.out.println("nameValue.getText()....."+nameValue.getText());
    			task.setName(nameValue.getText());
    		}
    		if(ownerValue.getText() != null && ownerValue.getText().trim().length() > 0){
    			//System.out.println("value of the name"+ownerValue.getText());
    			//System.out.println("value of the owener"+UserUtil.getUserMailId(ownerValue));
    			task.setOwner(UserUtil.getUserMailId(ownerValue));
    		}
    		if(stateCombo.getText() != null && stateCombo.getText().trim().length() > 0){
    			//System.out.println("task.setState(stateCombo.getText())....."+stateCombo.getText());
    			task.setState(stateCombo.getText());
    		}
    		if(EstimateValue.getText() != null && EstimateValue.getText().trim().length() > 0){
    			//System.out.println("EstimateValue.getText()...."+EstimateValue.getText());
    			task.setEstimate(new Double(EstimateValue.getText()));
    		}
    		if(toDoValue.getText() != null && toDoValue.getText().trim().length() > 0){
    			//System.out.println("toDoValue.getText()...."+toDoValue.getText());
    			task.setToDo(new Double(toDoValue.getText()));
    		}
    		
    		if(actualValue.getText() != null && actualValue.getText().trim().length() > 0){
    			//System.out.println("actualValue.getText()...."+actualValue.getText());
    			task.setActuals(new Double(actualValue.getText()));
    		}
    		//System.out.println("blockedCheck.getSelection()...."+blockedCheck.getSelection());
    		if(blockedCheck.getSelection()) 
    			
    			task.setBlocked(true);
    		else
    			task.setBlocked(false);
    		if(fixedCheckedINValue.getText() != null && fixedCheckedINValue.getText().trim().length() > 0){
    			task.setFixedCheckedIN(fixedCheckedINValue.getText());
    		}
    		/*if(workProd.getText() != null){
    			task.getWorkProduct().setRefObjectName(workProd.getText());
    		}
    			*/
          
    		if(addNoteValue.getText() != null && addNoteValue.getText().trim().length() > 0){
    			 java.util.GregorianCalendar calendar = new java.util.GregorianCalendar();
    	            String date = String.valueOf(calendar.get(Calendar.DATE));
    	            String month = String.valueOf(calendar.get(Calendar.MONTH));
    	            String year = String.valueOf(calendar.get(Calendar.YEAR));
    	            String hour = String.valueOf(calendar.get(Calendar.HOUR));
    	            String minute = String.valueOf(calendar.get(Calendar.MINUTE));
    	            String second = String.valueOf(calendar.get(Calendar.SECOND));
    	            
    	            String timeStamp = date+"/"+month+"/"+year+"::"+hour+":"+minute+":"+second;
    	            String user = HeaderPage.userNameFromRally;
    	    		String taskNotes = task.getNotes();
    			taskNotes += " <br> ["+timeStamp+" "+user+"]:"+addNoteValue.getText();
    			task.setNotes(taskNotes);
    		}
    		
    	    RallyMain.updateObject(task);
    		
    	}
    	
    }
}
